import time


def bubble_sort(sp):
    flag = False
    while flag == False:
        flag = True
        for i in range(len(sp) - 1):
            if sp[i] > sp[i + 1]:
                sp[i], sp[i + 1] = sp[i + 1], sp[i]
                flag = False
    return sp


files = ["m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"]
for file in files:
    f = open(file)
    sp = list(map(int, f.readlines()))
    time_start = time.time()
    bubble_sort(sp)
    time_end = time.time()
    print(f"{file[:len(file)-4]} {int((time_end-time_start)*1000)} milliseconds")
    f.close()